package com.pctx.permissionorder.controller;

import com.github.pagehelper.PageHelper;
import com.pctx.common.result.Result;
import com.pctx.permissionorder.pageHelper.PageInfo;
import com.pctx.permissionorder.pojo.PermissionOrder;
import com.pctx.permissionorder.service.PermissionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chason on 2018/3/2.11:17
 */
@RestController
@RequestMapping("permissionOrder")
public class PermissionOrderControoler {
    @Autowired
    private PermissionOrderService permissionOrderService;

    @GetMapping("page")
    public Result page(@RequestParam(value = "companyUuid" ,required = false) String companyUuid
            , @RequestParam(value = "status" ,required = false) Byte status, @RequestParam(value = "page", defaultValue = "1") Integer page
            , @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception{
        PageHelper.startPage(page,pageSize);
        List<PermissionOrder> list = permissionOrderService.getByCompanyUuidOrUserUuid(companyUuid,status);
        return Result.success(new PageInfo<PermissionOrder>(list));
    }
}
